﻿@{ ViewBag.Title = "Add";
    Layout = "~/Areas/Shared/_LayuiForm.cshtml"; }

<form class="layui-form">
    <input style="display:none" id="id" value="@ViewBag.ClassID">
    <div class="layui-form-item">
        <label class="layui-form-label required">通知标题</label>
        <div class="layui-input-block">
            <input type="text" name="Subject" id="Subject" placeholder="请输入标题" autocomplete="off" class="layui-input" lay-verify="required" maxlength="50">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">通知内容</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入通知内容" value="" name="Content" id="Content" class="layui-textarea" lay-verify="required"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="add">新 建</button>
        </div>
    </div>
</form>
<script>
    layui.use(["form", "exLayer", "exUtils"], function () {
        let form = layui.form;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;

        let $ = layui.$;

        form.render(); //

        form.on("submit(add)", function (data) {
            exUtils.ajax("/SysBasic/Notify/Add", "post", data.field, true).done(function (response) {
                exLayer.greenTickMsg(response.message, function () {
                    parent.layui.table.reload('tableId', { url: "/SysBasic/Notify/GetList" });
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                });
            }).fail(function (error) {
                console.log(error);
            });
            return false;
        });
    });
</script>